This week in Flutter #90: On architecture for Flutter applications
This issue of the newsletter contains a lot of architecture links. A couple of them are about Clean architecture in Flutter, using the BLoC pattern. The very last link, instead, is more about architecture in general in software projects.
You should start every project by defining its architecture. A good architecture document is a must if you want a project with high quality.
- Michele Volpato
🧑💻 Development in Flutter
A pragmatic guide to BuildContext in Flutter
by Daria Orlova
Do you think you know what BuildContext
is? Do you know what relationship it has
with Element
? What is the difference between StatelessWidget
and
StatefulWidget
regarding BuildContext
? Read this article and find out how
much you still don’t know about your widgets’ context. The article is
long and full of information.
Isolates in Flutter
Implementing concurrency was made easier in Dart 2.19. In this article, you learn what isolates are, and how easy it is to use them in your Flutter app to run heavy-duty code in the background.
“Clean” Architecture vs pragmatic architecture
There are many articles online about Clean architecture for Flutter apps. This one,
takes a slightly different approach, giving focus to what the app is about, rather
than talking about architecture for the sake of it. I do not agree with all the
choices: I believe that _PopularMoviesWidgetState
, a Flutter State
, should not
know about PopularMoviesRepository
, or any other repository in general, and
should only communicate with a use case, or BLoC in this example.
In my opinion, there should be a clear separation between the presentation layer (widgets) and the data layer (repositories). But this is also a decision you need to make as a team, so if the entire team agrees, then you are good to go.
Flutter BLoC + Clean Architecture Best Practice
And to stay on the topic of Clean architecture for Flutter, here is another approach, for comparison, that also uses BLoCs.
Dart Mixins Tutorial for Flutter: Getting Started
You might use mixins often in your Flutter apps, like SingleTickerProviderStateMixin
, or EquatableMixin
.
But what is a mixin, and when should you create your own?
🗄 Backend for Flutter developers
Dart Frog — Zero to Production
by Aseem Wangoo
Ok, you know how to use Flutter and Dart to write the presentation and business logic of your app. But what about the backend? Learn how to use Dart Frog, a backend framework for Dart.
🎥 Flutter videos
Observable Flutter: Live code review
with Craig Labenz
Craig reviews a mixture of user-submitted code and his own old, embarrassing code.
Preview: Two-dimensional scrolling in Flutter
with Kate Lovett
Flutter is introducing two dimensions scrolling in Flutter. It will solve the problem of having nested scroll views, which are not performing as well as the Flutter team would like.
👨💻 Software engineering in general
Investing Wisely in Architecture Through Refactoring
Should you worry about over-engineering your architecture or designs while refactoring? Should you follow guidelines set by others like Hexagonal, Clean, and Onion architectures, even if it will end up making the system more complex?
In my opinion, in non-trivial projects, it is always worth setting boundaries and rules from the very beginning. Think about “always having a use case between the data layer and the presentation layer, even when it is anemic.” Rules will make the code consistent, and a consistent code is much easier to maintain.
That’s it for this week.
If you want to comment on any of this week’s entries, you can do it in the comment section below.
Have a bug-free week,
- Michele Volpato
Leave a comment